<?php

namespace think\wework\Api;

use think\wework\Abstracts\WeworkApiWithToken;

class Corp extends WeworkApiWithToken
{
    private static ?Corp $instance = null;
    public static function getInstance(): Corp
    {
        if(!self::$instance instanceof Corp) {
            self::$instance = new self();
        }
        return self::$instance;
    }

    /**
     * 获取审批数据
     *
     * @param int $startTime
     * @param int $endTime
     * @param int $nextSPNum
     * @return array
     */
    public function getApprovalData(int $startTime, int $endTime, int $nextSPNum = 0): array
    {
        $json = [
            'starttime' => $startTime,
            'endtime' => $endTime
        ];

        if ($nextSPNum > 0) {
            $json['next_spnum'] = $nextSPNum;
        }

        return $this->httpClient->post('corp/getapprovaldata', compact('json'))->toArray();
    }
}
